package field关键字

class Player {
    var name: String = "jack"
        get() = field.capitalize()
        set(value) {
            field = value.trim()
        }
}

fun main() {
    val p = Player()
    println(p.name)
    p.name = " rose "
    println(p.name)
}